package com.example.chapter4.controller;

import com.example.chapter4.mapper.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
public class StudentController {
    @Autowired
    StudentMapper studentMapper;
    @GetMapping(value = "/student/{id}")
    public Object student(@PathVariable("id") int id){
//        Map<String,Object> map=new HashMap<>();
//        map.put("id",id);
//        map.put("name","张三");
//        map.put("qq","123456");
//        return map;
        return studentMapper.findStudentById(id);
    }
    @GetMapping(value = "/student/{id}/{qq}")
    public Object student(@PathVariable("id") int id,@PathVariable("qq") String qq){
        Map<String,Object> map=new HashMap<>();
        map.put("id",id);
        map.put("qq",qq);
        return map;
    }
    @DeleteMapping(value = "/student/detail/{id}/{status}")
    public Object student2(@PathVariable("id") int id,@PathVariable("status") Integer status){
        Map<String,Object> map=new HashMap<>();
        map.put("id",id);
        map.put("status",status);
        return map;
    }
    @PostMapping(value = "/student/{id}")
    public String addStudent(@PathVariable("id") int id){
        return "add student ID:"+id;
    }
    @PutMapping(value = "/student/{id}")
    public String updateStudent(@PathVariable("id") int id){
        return "update student ID:"+id;
    }



}
